var dxdanList = new Vue({
  el: '#dxdanList',
  data:{
  refreshing:true,
	count:0,
	fammerName:'',
	farmerId:'',
	list:[]
  },
  mounted:function(){
		this.fammerName = localStorage.fammername
		this.farmerId = localStorage.fammerid
		this.getDxdanList()
  },
  methods:{
  	getDxdanList:function(){
  		var _this = this
  		axios({
				url: sever + '/dxdanList',
				method: 'POST',
				// 请求体重发送的数据
				params: {
					farmerId:_this.farmerId
				},
				timeout: 50000,
				// 设置请求头
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
			}).then(function(res){
				_this.list = res.data.list
				_this.pullupRefresh()
			})
  	},
  	pullupRefresh:function(){
 
			var _this = this
				_this.refreshing = true
				setTimeout(function() {
									
					
					var table = document.body.querySelector('.mui-table-view');
					var cells = document.body.querySelectorAll('.mui-table-view-cell');
					 		console.log((cells.length==_this.list.length))
					mui('#dxdanList').pullRefresh().endPullupToRefresh((cells.length==_this.list.length)); //参数为true代表没有更多数据了。

					//var newCount = cells.length>0?5:20;//首次加载20条，满屏
					for (var i = cells.length, len = i + _this.list.length-cells.length; i < len; i++) {
						var li = document.createElement('li');
						li.className = 'mui-table-view-cell';
						li.innerHTML = '<a class="mui-navigate-right">' + _this.list[i].des+ '</a>';
						table.appendChild(li);
					}
					_this.refreshing = false
				}, 1500);
		},
		pulldownRefresh:function(){
			var _this = this		
			setTimeout(function() {		
					mui('#dxdanList').pullRefresh().endPulldownToRefresh();		
					_this.getDxdanList()
				}, 1500);
		}
  },
});